Sooooo nothing with BEC zones has been promising so far. Let’s try something else. Let’s switch to VRI data and see if amount of mature/old growth forest is related to amount of squirrel in the diet, since squirrels like old forests.
library(AICcmodavg)
Error in library(AICcmodavg) : there is no package called ‘AICcmodavg’
That’s remarkably consistent.
The next step is to get the amount of mature forest for each of these sites. Unfortunately, the VRI data for Turbid Creek is useless so that drops me down to five sites. But I can pull in the VRI for the others…
# Import transition zone shapefile.
vri <- st_read('../data/external/VRI_camera-sites_2019.shp')
Reading layer `VRI_camera-sites_2019' from data source `C:\Users\gwync\sfuvault\productivity-occupancy\data\external\VRI_camera-sites_2019.shp' using driver `ESRI Shapefile'
Simple feature collection with 13321 features and 188 fields
geometry type: POLYGON
dimension: XY
bbox: xmin: 413289.1 ymin: 5428268 xmax: 645675.7 ymax: 5589928
projected CRS: WGS 84 / UTM zone 10N
Then I need to rasterize it. Which means first I need to break it down into classes so I can assign a raster value. Unfortunately there’s no single field in the VRI data that works for classification. I can break this into:
# Assign to classes.
# Regen/young/mature/old ages come from Zharikov et al. 2007
vri.class <- vri %>% mutate(hab.class=case_when(
# Non-vegetated and water
BCLCS_LV_1 == 'N' & BCLCS_LV_2 == 'W' ~ 1,
# Non-vegetated and not water
BCLCS_LV_1 == 'N' & BCLCS_LV_2 != 'W' ~ 2,
# Vegetated and not trees
BCLCS_LV_1 == 'V' & BCLCS_LV_2 == 'N' ~ 3,
# Vegetated and mixed or deciduous trees
BCLCS_LV_1 == 'V' & BCLCS_LV_4 %in% c('TB', 'TM') ~ 4,
# Vegetated and coniferous trees
BCLCS_LV_4 == 'TC' & PROJ_AGE_1 < 20 ~ 5,
BCLCS_LV_4 == 'TC' & PROJ_AGE_1 >= 20 & PROJ_AGE_1 < 60 ~ 6,
BCLCS_LV_4 == 'TC' & PROJ_AGE_1 >= 60 & PROJ_AGE_1 < 140 ~ 7,
BCLCS_LV_4 == 'TC' & PROJ_AGE_1 >= 140 ~ 8,
TRUE ~ 0
))
# See how it turned out.
vri.class %>% group_by(hab.class) %>% summarise(n())
`summarise()` ungrouping output (override with `.groups` argument)
Simple feature collection with 9 features and 2 fields
geometry type: MULTIPOLYGON
dimension: XY
bbox: xmin: 413289.1 ymin: 5428268 xmax: 645675.7 ymax: 5589928
projected CRS: WGS 84 / UTM zone 10N